package com.mydemo.io.socket;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Random;

/**
 * <p></p >
 */
public class SocketDemo {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost", 8080);
        OutputStream outputStream = socket.getOutputStream();
        Random random = new Random();
        int i = random.nextInt();
        System.out.println("发送信息:" + i);
        outputStream.write((i + "中国").getBytes());
        socket.shutdownOutput();
        outputStream.flush();
    }
}
